<template>
	<view class="content">
		<view class="historyList">
			<view class="hisli" v-for="(item,index) in listData" :key="index" @click="goDetail(item)">
				<view class="hisTop">
					<view class="hisTitle">
						{{item.deviceName}}
					</view>
					<text :class="'stt' + item.status">{{item.status | sttFmt}}</text>
				</view>
				<view class="hisInfo">
					<view class="hisTxt">
						单位联系人：<text>{{item.contactName}}({{item.contactPhone}})</text> 
					</view>
					<view class="hisTxt">
						单位地址：<text>{{item.contactAddress}}</text>
					</view>
					<view class="hisTxt">
						计划服务时间：<text>{{item.appointmentTimePeriod}}</text>
					</view>
					<view class="hisTxt">
						服务工程师：<text>{{item.mastTxt}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getRepairorder } from '@/api/login.js';
	export default {
		data() {
			return {
				queryItem:{
					status: '',
					pageSize: 20,
					pageNum: 1
				},
				listData: []
			}
		},
		onLoad() {
			this.queryItem.masterId = uni.getStorageSync('userInfo').id;
			this.getListData();
		},
		filters:{
			sttFmt(val) {
				if(val == 1) {
					return '待分配';
				} else if(val == 2) {
					return '待服务';
				} else if(val == 3) {
					return '服务中';
				} else if(val == 4) {
					return '已完成';
				} else if(val == 5) {
					return '已评价';
				}
			}
		},
		methods: {
			goDetail(val){
				uni.navigateTo({
					url: '/pages/engineer/taskForm?idd=' + val.id + '&optype=2'
				});
			},
			getListData(){
				uni.showLoading({
					title: '加载中...'
				});
				getRepairorder(this.queryItem).then(res=>{
					uni.hideLoading();
					if(res.code == 200) {
						res.rows.forEach(item=>{
							item.mastTxt = item.masterList.map((x) => x.masterName).join(",");
						})
						this.listData = res.rows;
					} else {
						uni.$u.toast(res.msg);
					}	
				})
			}
		}
	}
</script>

<style scoped lang="scss">
.content{
	background-color: #F4F4F4;padding:18rpx 24rpx;min-height: 100vh;
	.historyList{
		.hisli{
			background-color:#fff;border-radius:8rpx;margin-bottom:16rpx;
			.hisTop{
				border-bottom:2rpx solid #F4F4F4;
				@include flx;align-items: center;justify-content: space-between;padding:0 28rpx 0 26rpx;
				.hisTitle{
					@include baseFont(32rpx,#333,118rpx);font-weight:500;padding-left:94rpx;
					background: url('../../static/qy.png') no-repeat left center;background-size:72rpx;
				}
				text{
					display: block;width: 132rpx;height: 48rpx;background: #E9E9E9;
					border-radius: 8rpx;text-align: center;@include baseFont(28rpx,#666,48rpx);
				}
				.stt1,.stt2{
					background: rgba(7,191,165,0.12);color:#07BFA5;
				}
				.stt3{
					background: rgba(54,113,233,0.16);color:#3671E9;
				}
				.stt4{
					background: rgba(221,71,33,0.12);color:#DD4721;
				}
				.stt5{
					background: rgba(255,164,27,0.2);color:#EC6A38;
				}
			}
			.hisInfo{
				padding:20rpx 28rpx 14rpx 26rpx;
				.hisTxt{
					@include baseFont(28rpx,#8D8D8D,36rpx);margin-bottom:12rpx;
					text{
						color:#333;
					}
				}
			}
		}
	}
}
</style>
